#ifndef PRIMARYKEYCONSTRAINT_H
#define PRIMARYKEYCONSTRAINT_H

#include "tableconstraint.h"

// forward declaration:
class ColumnList;
class Column;

/*
    Class: PrimaryKeyConstraint
    Storage the columns than compose the primary key of an SQL table.
*/
class PrimaryKeyConstraint : public TableConstraint
{
    /* Section: public */
    public:
        /*
            Constructor: Default constructor.
            Initializes the object.
        */
        PrimaryKeyConstraint(ColumnList * columns = NULL);

        /*
            Destructor: Default destructor.
            Destroy the object.
        */
        virtual ~PrimaryKeyConstraint();

        /*
            Constructor: Copy constructor.
            Initializes the object as a copy from other PrimaryKeyConstraint object.

            Parameter:
                other   -   PrimaryKeyConstraint to copy from.
        */
        PrimaryKeyConstraint(const PrimaryKeyConstraint& other);

        /*
            Method: AddColumn
            Adds a columns to the primary key column list.

            Parameters:
                column  -   Column to add.
        */
        void addColumn(Column * column);

        /*
            Method: addColumn
            Adds a column to the primary key constraint.

            Parameters:
                column - name of the column.
        */
        void addColumn(const string & column);

        /*
            Method: SetColumns
            Sets the columns that compose the primery key. Destroy the previous list of columns if any.

            Parameters:
                columns -   Columns to set as the primary key.
        */
        void setColumns(ColumnList * columns);

        /*
            Method: GetColumns
            Returns:
                The columns that compose the primary key.
        */
        ColumnList * getColumns() const;

        /*
            Method: ToString

            See also:
                Constraint.
        */
        virtual string toString();

        /*
            Method: Clone

            See also:
                TableConstraint
        */
        virtual TableConstraint * clone();

    /* Section: private */
    private:
        /*
            Variable: columns
            Type: ColumnList
            Columns that compose the primary key.
        */
        ColumnList * columns;
};

#endif // PRIMARYKEYCONSTRAINT_H
